package com.ruoyi.school.arrti.service.impl;

import java.util.List;

import com.ruoyi.school.arrti.query.AttireQuery;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.school.arrti.mapper.AttireMapper;
import com.ruoyi.school.arrti.domain.Attire;
import com.ruoyi.school.arrti.service.IAttireService;

/**
 * 心理设备Service业务层处理
 *
 * @author duanxinli
 * @date 2023-10-30
 */
@Service
public class AttireServiceImpl implements IAttireService {
    @Autowired
    private AttireMapper attireMapper;


    /**
     * 查询心理设备
     *
     * @param id 心理设备主键
     * @return 心理设备
     */
    @Override
    public Attire selectAttireById(String id) {
        return attireMapper.selectAttireById(id);
    }

    /**
     * 查询心理设备列表
     *
     * @param attireQuery 心理设备
     * @return 心理设备
     */
    @Override
    public List<Attire> selectAttireList(AttireQuery attireQuery) {
        if (attireQuery.getDateRange() != null) {
            attireQuery.setCreateStart(attireQuery.getDateRange().get(0));
            attireQuery.setCreateEnd(attireQuery.getDateRange().get(1));
        }
        List<Attire> queryAttreList = attireMapper.selectAttireList(attireQuery);
        return queryAttreList;
    }

    /**
     * 新增心理设备
     *
     * @param attire 心理设备
     * @return 结果
     */
    @Override
    public int insertAttire(Attire attire) {
        attire.setId(IdUtils.fastUUID());
        attire.setCreateDate(DateUtils.getNowDate());
        String username = SecurityUtils.getUsername();
        attire.setCreateBy(username);
        attire.setSort(0L);
        attire.setDelFlag(0L);
        return attireMapper.insertAttire(attire);
    }

    /**
     * 修改心理设备
     *
     * @param attire 心理设备
     * @return 结果
     */
    @Override
    public int updateAttire(Attire attire) {
        return attireMapper.updateAttire(attire);
    }

    /**
     * 批量删除心理设备
     *
     * @param ids 需要删除的心理设备主键
     * @return 结果
     */
    @Override
    public int deleteAttireByIds(String[] ids) {
        return attireMapper.deleteAttireByIds(ids);
    }

    /**
     * 删除心理设备信息
     *
     * @param id 心理设备主键
     * @return 结果
     */
    @Override
    public int deleteAttireById(String id) {
        return attireMapper.deleteAttireById(id);
    }
}
